import service from '@/utils/request'

export const useMetadataApi = (id: number) => {
	return service.get('/data-governance/metadata/' + id)
}

export const useMetadataSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/data-governance/metadata', dataForm)
	} else {
		return service.post('/data-governance/metadata', dataForm)
	}
}

export const listChildApi = (parentId: number) => {
	return service.get('/data-governance/metadata/list-child?parentId='+parentId)
}

export const delTreeNodeApi = (id: number) => {
	return service.delete('/data-governance/metadata/'+id)
}

export const listMetamodelPropertyApi = (metaModelId: number) => {
	return service.get('/data-governance/metamodel-property/properties/'+metaModelId)
}

export const listKeywordApi = (keyword: any) => {
	return service.get('/data-governance/metadata/list-keyword?keyword='+keyword)
}

export const listMetadataFloderApi = () => {
	return service.get('/data-governance/metadata/list-floder')
}

export const updateNeo4jApi = (dataForm: any) => {
	return service.post('/data-governance/metadata/neo4j', dataForm)
}

export const getNeo4jApi = () => {
	return service.get('/data-governance/metadata/neo4j')
}

export const listDbApi = () => {
	return service.get('/data-governance/metadata/list-db')
}

// 获取数据库
export const getSqlList = () => {
    return service({
        url: '/data-integrate/database',
        method: 'get',
    });
}

// 库表同步分页数据
export const getMetadataSyncPage = (data) => {
	return service({
		url: '/data-governance/Metadata-Sync/page',
		method: 'get',
		params: data
	});
}

// 未建表  建表失败的数据表
export const getMetadataSyncList = (data) => {
	return service({
		url: '/data-governance/Metadata-Sync/chose',
		method: 'get',
		params: data
	});
}

// 获取已建表 没有同步的数据表
export const getMetadataSyncNotList = (data) => {
    return service({
		url: '/data-governance/Metadata-Sync/listSync',
		method: 'get',
		params: data
	});
}


// 元数据 建表
export const createMateTable = (data) => {
    return service({
        url: '/data-governance/Metadata-Sync/save',
        method: 'post',
        data: data
    })
}

// 元数据同步
export const metadataSync = (data) => {
    return service({
        url: '/data-governance/Metadata-Sync/sync',
        method: 'put',
        data: data
    })
}

//获取是否有库表的建表任务
export const getMetadataSyncTask = (data) => {
    return service({
        url: '/data-governance/Metadata-Sync/task/status',
        method: 'post',
        params: data
    })
}